<?php
class ControllerCatalogActivity extends Controller {
    public function index() {
        
        $this->load->model('marketing/marketing');
        
        if (isset($this->request->get['client'])) {
            $client = $this->request->get['client'];
        } else {
            $client = 'common';
        }
        
        if (isset($this->request->get['page'])) {
            $page = $this->request->get['page'];
        } else {
            $page = 1;
        }
        
        if (isset($this->request->get['limit'])) {
            $limit = $this->request->get['limit'];
        } else {
            $limit = $this->config->get('config_product_limit');
        }
        
        $marketing_total = $this->model_marketing_marketing->getTotalMarketings();
        
        $marketings = $this->model_marketing_marketing->getMarketings(($page - 1) * $limit, $limit);
        
        foreach ($marketings as $marketing) {
            $data['activities'][] = array(
                'image'       => $marketing['image'],
                'name'        => $marketing['name'],
                'code'           => $marketing['code'],
                'description'    => $marketing['description'],
                'link'           => $marketing['link']
            );
        }
        
        $data['total'] = $marketing_total;
        $data['pageIndex'] = $page;
        $data['pageSize'] = $limit;
        
        $this->response->setDataResult(1,"",$data);
        
    }
}